home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / mach / sun4.md / machConst.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-19  |  19.0 KB  |  566 lines

  1. /*
  2.  * machConst.h --
  3.  *
  4.  *     Machine dependent constants.
  5.  *
  6.  * Copyright (C) 1985 Regents of the University of California
  7.  * All rights reserved.
  8.  *
  9.  *
  10.  * $Header: /cdrom/src/kernel/Cvsroot/kernel/mach/sun4.md/machConst.h,v 9.13 92/08/10 17:58:53 mgbaker Exp $ SPRITE (Berkeley)
  11.  */
  12.  
  13. #ifndef _MACHCONST
  14. #define _MACHCONST
  15.  
  16. #ifdef KERNEL
  17. #include <sprite.h>
  18. #include <vmSunConst.h>
  19. #include <sysSysCall.h>
  20. #include <sys.h>
  21. #include <status.h>
  22. #else
  23. #include <kernel/vmSunConst.h>
  24. #include <kernel/sysSysCall.h>
  25. #include <kernel/sys.h>
  26. #include <status.h>
  27. #endif
  28.  
  29.  
  30. /*
  31.  * Return codes from some trap routines.
  32.  *
  33.  *    MACH_OK        Successfully handled.
  34.  *    MACH_KERN_ERROR    Debugger must be called.
  35.  *    MACH_USER_ERROR    User process error (bad stack, etc).  Kill user process.
  36.  *    MACH_SIG_RETURN    Returning from signal handler.
  37.  *
  38.  */
  39. #define    MACH_OK        0
  40. #define    MACH_KERN_ERROR    1
  41. #define    MACH_USER_ERROR    2
  42. #define    MACH_SIG_RETURN    3
  43.  
  44. /*
  45.  * Here are the different types of exceptions, represented by the contents
  46.  * of the trap type bits in the trap base register..  These are listed in order
  47.  * of highest priority to lowest. All the MACH_TRAP_INSTR's are of the same
  48.  * priority.
  49.  *
  50.  * Trap Name            Trap Type Field
  51.  */
  52. #define    MACH_RESET        0x000
  53. #define    MACH_INSTR_ACCESS    0x010
  54. #define    MACH_ILLEGAL_INSTR    0x020
  55. #define    MACH_PRIV_INSTR        0x030
  56. #define    MACH_FP_DISABLED    0x040
  57. #define    MACH_CP_DISABLED    0x240        /* 36 */
  58. #define    MACH_WINDOW_OVERFLOW    0x050
  59. #define    MACH_WINDOW_UNDERFLOW    0x060
  60. #define    MACH_MEM_ADDR_ALIGN    0x070
  61. #define    MACH_FP_EXCEP        0x080
  62. #define    MACH_CP_EXCEP        0x280        /* 40 */
  63. #define    MACH_DATA_ACCESS    0x090
  64. #define    MACH_TAG_OVERFLOW    0x0a0
  65. #define    MACH_TRAP_INSTR_FIRST    0x800        /* 128 */
  66. #define    MACH_TRAP_INSTR_1    0x810        /* 129 */
  67. #define    MACH_TRAP_INSTR_2    0x820        /* 130 */
  68. #define    MACH_TRAP_INSTR_3    0x830        /* 131 */
  69. #define    MACH_TRAP_INSTR_4    0x840        /* 132 */
  70. #define    MACH_TRAP_INSTR_5    0x850        /* 133 */
  71. #define    MACH_TRAP_INSTR_LAST    0xff0
  72.  
  73. #define    MACH_LEVEL0_INT        0x100        /* 16 */
  74. #define    MACH_LEVEL1_INT        0x110        /* 17 */
  75. #define    MACH_LEVEL2_INT        0x120
  76. #define    MACH_LEVEL3_INT        0x130
  77. #define    MACH_LEVEL4_INT        0x140
  78. #define    MACH_LEVEL5_INT        0x150
  79. #define    MACH_LEVEL6_INT        0x160
  80. #define    MACH_LEVEL7_INT        0x170
  81. #define    MACH_LEVEL8_INT        0x180
  82. #define    MACH_LEVEL9_INT        0x190
  83. #define    MACH_LEVEL10_INT    0x1a0
  84. #define    MACH_LEVEL11_INT    0x1b0
  85. #define    MACH_LEVEL12_INT    0x1c0
  86. #define    MACH_LEVEL13_INT    0x1d0
  87. #define    MACH_LEVEL14_INT    0x1e0
  88. #define    MACH_LEVEL15_INT    0x1f0
  89.  
  90. #define    MACH_TRAP_UNIX_SYSCALL    MACH_TRAP_INSTR_FIRST
  91. #define    MACH_TRAP_DEBUGGER    MACH_TRAP_INSTR_1
  92. #define    MACH_TRAP_SYSCALL    MACH_TRAP_INSTR_3
  93. #define    MACH_TRAP_SIG_RETURN    MACH_TRAP_INSTR_4
  94. #define    MACH_TRAP_FLUSH_WINDOWS    MACH_TRAP_INSTR_5
  95.  
  96. /*
  97.  * Our trap type is the 2 second to the last hex digits of the tbr register.
  98.  * So "trap type 3" shows up in the last 3 digits of the tbr as 0x030, and
  99.  * trap type 15 shows up as 0x1f0.  The trap types for the software trap
  100.  * instructions start at trap type 128 (0x800 in the tbr).  To get the arguments
  101.  * to a software trap instruction, we take the trap type, subtract off 0x800,
  102.  * and then shift it right by 4 bits to chop off the lowest hex digit.
  103.  * Thus the trap instruction "ta 0" has a trap type of 128 == 0x80 (== 0x800 in
  104.  * the tbr), and ta 1 has a trap type of 129 showing up as 0x810 in the tbr.
  105.  */
  106. /* trap instruction number is trap type - trap type 128 = 0x80 (== -0x800) */
  107. #define    MACH_CALL_DBG_TRAP    ((MACH_TRAP_DEBUGGER - 0x800) >>4)
  108. #define    MACH_BRKPT_TRAP        ((MACH_TRAP_INSTR_2 - 0x800) >>4)
  109. #define    MACH_SYSCALL_TRAP    ((MACH_TRAP_SYSCALL - 0x800) >> 4)
  110. #define    MACH_RET_FROM_SIG_TRAP    ((MACH_TRAP_SIG_RETURN - 0x800) >> 4)
  111. #define    MACH_FLUSH_WINDOWS_TRAP    ((MACH_TRAP_FLUSH_WINDOWS - 0x800) >> 4)
  112.  
  113. /*
  114.  * Mask for extracting the trap type from the tbr.
  115.  */
  116. #define    MACH_TRAP_TYPE_MASK    0xFF0
  117. /*
  118.  * Mask for extracting the trap base address from the tbr.
  119.  */
  120. #define MACH_TRAP_ADDR_MASK    0xFFFFF000
  121.  
  122. /*
  123.  *  Masks for 16 interrupt priority levels:
  124.  *   lowest = 0,   highest = 15.
  125.  */
  126. #define    MACH_SR_PRIO_0        0x0000
  127. #define    MACH_SR_PRIO_1        0x0100
  128. #define    MACH_SR_PRIO_2        0x0200
  129. #define    MACH_SR_PRIO_3        0x0300
  130. #define    MACH_SR_PRIO_4        0x0400
  131. #define    MACH_SR_PRIO_5        0x0500
  132. #define    MACH_SR_PRIO_6        0x0600
  133. #define    MACH_SR_PRIO_7        0x0700
  134. #define    MACH_SR_PRIO_8        0x0700
  135. #define    MACH_SR_PRIO_9        0x0700
  136. #define    MACH_SR_PRIO_10        0x0700
  137. #define    MACH_SR_PRIO_11        0x0700
  138. #define    MACH_SR_PRIO_12        0x0700
  139. #define    MACH_SR_PRIO_13        0x0700
  140. #define    MACH_SR_PRIO_14        0x0700
  141. #define    MACH_SR_PRIO_15        0x0700
  142.  
  143. /*
  144.  *  State priorities in the processor state register (psr):
  145.  *
  146.  *    MACH_SR_HIGHPRIO    Supervisor mode + interrupts disabled, traps on
  147.  *    MACH_SR_LOWPRIO        Supervisor mode + interrupts enabled, traps on
  148.  *    MACH_SR_USERPRIO    User mode, traps on
  149.  *
  150.  *    For the sun4, these are macros in machAsmDefs.h.  I can't just move
  151.  *    values into the psr the way the sun3 and sun2 do, since that would
  152.  *    change the window we're in, etc.
  153.  */
  154.  
  155. /*
  156.  * Constants to access bits in the psr register.
  157.  */
  158. #define    MACH_ENABLE_INTR        0xFFFFF0FF    /* and with psr */
  159. #define    MACH_DISABLE_INTR        (~MACH_ENABLE_INTR)    /* or w/ psr */
  160. #define MACH_ENABLE_FPP            0x1000
  161. #define    MACH_CWP_BITS            0x1f    /* cwp bits in psr */
  162. #define    MACH_ENABLE_TRAP_BIT        0x20    /* or with %psr */
  163. #define    MACH_DISABLE_TRAP_BIT        0xFFFFFFDF    /* and with %psr */
  164. #define    MACH_SUPER_BIT            0x80
  165. #define    MACH_PS_BIT            0x40    /* and with psr - prev. state */
  166. #define    MACH_FIRST_USER_PSR        0x080    /* traps off, interrupts on,
  167.                          * previous mode not supervisor,
  168.                          * current mode supervisor. */
  169. #define    MACH_PSR_SIG_RESTORE        0xF00000 /* Bits to restore from sig */ 
  170. #define    MACH_NO_INTR_USER_PSR        0xF80
  171. #define MACH_CARRY_BIT            0x00100000
  172. #define MACH_CARRY_BITMASK        (~MACH_CARRY_BIT)
  173. /*
  174.  * psr value for interrupts disabled, traps enabled and window 0.
  175.  * Both supervisor and previous supervisor mode bits are set.
  176.  */
  177. #define    MACH_HIGH_PRIO_PSR        0x00000FE0
  178.  
  179. /*
  180.  * FPU fsr bits.
  181.  */
  182.  
  183. #define    MACH_FSR_QUEUE_NOT_EMPTY     0x2000
  184. #define    MACH_FSR_TRAP_TYPE_MASK        0x1c000
  185. #define    MACH_FSR_NO_TRAP        0x00000
  186. #define    MACH_FSR_IEEE_TRAP        0x04000
  187. #define    MACH_FSR_UNFINISH_TRAP        0x08000
  188. #define    MACH_FSR_UNIMPLEMENT_TRAP    0x0c000
  189. #define    MACH_FSR_SEQ_ERRROR_TRAP    0x10000
  190.  
  191. /*
  192.  * Bits to enable interrupts in interrupt register.
  193.  */
  194. #define    MACH_ENABLE_ALL_INTERRUPTS    0x1
  195. #define    MACH_ENABLE_LEVEL1_INTR        0x2
  196. #define    MACH_ENABLE_LEVEL4_INTR        0x4
  197. #define    MACH_ENABLE_LEVEL6_INTR        0x8
  198. #define    MACH_ENABLE_LEVEL8_INTR        0x10
  199. #define    MACH_ENABLE_LEVEL10_INTR    0x20
  200. #define    MACH_ENABLE_LEVEL14_INTR    0x80
  201. /*
  202.  * Bit to enable in interrupt register for timer.
  203.  */
  204. #ifdef sun4c
  205. #define    MACH_ENABLE_COUNTER0_INTR_LEVEL    MACH_ENABLE_LEVEL10_INTR
  206. #define    MACH_ENABLE_COUNTER1_INTR_LEVEL    MACH_ENABLE_LEVEL14_INTR
  207. #else
  208. #define    MACH_ENABLE_TIMER_INTR_LEVEL    MACH_ENABLE_LEVEL10_INTR
  209. #endif
  210.  
  211. /*
  212.  * Bits to access bus error register.
  213.  */
  214. #ifdef sun4c
  215. #define    MACH_SIZE_ERROR        0x02
  216. #define    MACH_SB_ERROR        0x10
  217. #define    MACH_TIMEOUT_ERROR    0x20
  218. #define    MACH_PROT_ERROR        0x40
  219. #define    MACH_INVALID_ERROR    0x80
  220. #else
  221. #define    MACH_SIZE_ERROR        0x02
  222. #define    MACH_VME_ERROR        0x10
  223. #define    MACH_TIMEOUT_ERROR    0x20
  224. #define    MACH_PROT_ERROR        0x40
  225. #define    MACH_INVALID_ERROR    0x80
  226. #endif
  227.  
  228. /*
  229.  * MACH_KERN_START    The address where the kernel image is loaded at.
  230.  * MACH_CODE_START    The address where the kernel code is loaded at.
  231.  * MACH_STACK_START The address of the base of the stack.  1st word is unusable.
  232.  * MACH_STACK_BOTTOM    The address of the bottom of the kernel stack for the
  233.  *            main process that is initially run.
  234.  * MACH_KERN_END    The address where the last kernel virtual address is
  235.  *            at.
  236.  * MACH_KERN_STACK_SIZE Number of bytes in a kernel stack.
  237.  * MACH_BARE_STACK_OFFSET    Offset of where a bare kernel stack starts.
  238.  *                It doesn't start at the very top because
  239.  *                the debugger requires a couple of integers
  240.  *                of padding on the top.
  241.  * MAGIC        A magic number which is pushed onto the stack before
  242.  *            a context switch.  Used to verify that the stack
  243.  *            doesn't get trashed.
  244.  * MACH_UNIX_ERRNO_OFFSET    Errno offset in Proc_ControlBlock
  245.  */
  246. #define    MACH_KERN_START        0xf6000000
  247. #define    MACH_STACK_START    (MACH_KERN_START + MACH_KERN_STACK_SIZE)
  248. #define    MACH_CODE_START        (MACH_STACK_START + 0x20)
  249. #define    MACH_STACK_BOTTOM    MACH_KERN_START
  250. #define MACH_KERN_END        VMMACH_NET_MAP_START
  251. #define    MACH_KERN_STACK_SIZE    0x6000
  252. #define    MACH_BARE_STACK_OFFSET    (MACH_KERN_STACK_SIZE - 8)
  253. #define    MACH_UNIX_ERRNO_OFFSET    696    /* Offset checked in Mach_Init. */
  254.  
  255. /*
  256.  * Constants for the user's address space.
  257.  *
  258.  * MACH_FIRST_USER_ADDR        The lowest possible address in the user's VAS.
  259.  * MACH_LAST_USER_ADDR        The highest possible address in the user's VAS.
  260.  * MACH_LAST_USER_STACK_PAGE    The highest page in the user stack segment.
  261.  * MACH_MAX_USER_STACK_ADDR    The highest value that the user stack pointer
  262.  *                can have.  Note that the stack pointer must be
  263.  *                decremented before anything can be stored on
  264.  *                the stack.  Also note that on the sun4 we must
  265.  *                strip off the high couple of bits, since 0's
  266.  *                and 1's in them point to the same entry in the
  267.  *                segment table.
  268.  *                ACTUALLY: it turns out we can't just strip
  269.  *                those bits, since doing so may put us in the
  270.  *                invalid hole, since the kernel doesn't start
  271.  *                right at the bottom of the top part after the
  272.  *                hole.  I'll have to deal with the user stack
  273.  *                not being contiguous in some way, so it can
  274.  *                start beneath the kernel and continue across
  275.  *                the hole, but for now, I just shrink everything
  276.  *                so the user process stack must start at the
  277.  *                top address beneath the hole.  Yuckola.
  278.  *
  279.  */
  280. #define    MACH_FIRST_USER_ADDR        VMMACH_PAGE_SIZE
  281. #define    MACH_LAST_USER_ADDR        (VMMACH_BOTTOM_OF_HOLE - 1)
  282. #define    MACH_LAST_USER_STACK_PAGE    ((MACH_MAX_USER_STACK_ADDR - 1) / VMMACH_PAGE_SIZE)
  283. #define    MACH_MAX_USER_STACK_ADDR    VMMACH_SHARED_START_ADDR
  284.  
  285. /*
  286.  * The control space offset of the VME interrupt vector.
  287.  */
  288. #define    MACH_VME_INTR_VECTOR        0xE0000000
  289.  
  290. /*
  291.  * Instruction executed from stack to cause a return trap to the kernel from
  292.  * a signal handler.  This is "ta MACH_RET_FROM_SIG_TRAP" instruction.
  293.  */
  294. #define    MACH_SIG_TRAP_INSTR    0x91d02004
  295. /*
  296.  * Constants for getting to offsets in structures:  To make sure these
  297.  * constants are correct, there is code in machCode.c that will cause
  298.  * the kernel to die upon booting if the offsets aren't what's here.
  299.  * All sizes are in bytes.
  300.  */
  301. /*
  302.  * Byte offsets from beginning of a Mach_RegState structure to the fields
  303.  * for the various types of registers.
  304.  */
  305. #define    MACH_LOCALS_OFFSET    0
  306. #define    MACH_INS_OFFSET        (MACH_LOCALS_OFFSET + MACH_NUM_LOCALS * 4)
  307. #define    MACH_GLOBALS_OFFSET    (MACH_INS_OFFSET + (MACH_NUM_INS * 2) * 4 + \
  308.                  MACH_NUM_EXTRA_ARGS * 4)
  309. #define    MACH_FPU_FSR_OFFSET    (MACH_GLOBALS_OFFSET + (MACH_NUM_GLOBALS * 4))
  310. #define    MACH_FPU_QUEUE_COUNT    (MACH_FPU_FSR_OFFSET + 4)
  311. #define    MACH_FPU_REGS_OFFSET    (MACH_FPU_QUEUE_COUNT + 4)
  312. #define    MACH_FPU_QUEUE_OFFSET    (MACH_FPU_REGS_OFFSET + (MACH_NUM_FPS * 4))
  313.  
  314. #define    MACH_SIG_STUFF_SIZE    ((MACH_SAVED_STATE_FRAME + 8 + 4) + 20)
  315.                         /* skip over calleeInputs too */
  316. /*
  317.  * Byte offset from beginning of a Mach_State structure to various register
  318.  * fields, the savedSps field, the savedRegs field, the savedMask field, 
  319.  * the kernStackStart, and the FPU status field.
  320.  */
  321. #define    MACH_TRAP_REGS_OFFSET    0
  322. #define    MACH_SWITCH_REGS_OFFSET    (MACH_TRAP_REGS_OFFSET + 4)
  323. #define    MACH_SAVED_REGS_OFFSET    (MACH_SWITCH_REGS_OFFSET + 4)
  324.  
  325. #define    MACH_SAVED_MASK_OFFSET    (MACH_SAVED_REGS_OFFSET + (MACH_MAX_WINDOWS *\
  326.                 MACH_NUM_WINDOW_REGS * 4))
  327. #define    MACH_SAVED_SPS_OFFSET    (MACH_SAVED_MASK_OFFSET + 4)
  328. #define    MACH_KSP_OFFSET        (MACH_SAVED_SPS_OFFSET + (MACH_MAX_WINDOWS * 4))
  329. #define    MACH_FPU_STATUS_OFFSET  (MACH_KSP_OFFSET + 4)
  330.  
  331. /*
  332.  * Maximum number of processors configurable.
  333.  */
  334.  
  335. #define    MACH_MAX_NUM_PROCESSORS        1
  336.  
  337. /*
  338.  * Fast restart constants.
  339.  */
  340. #ifndef RECOV_NOCOPY
  341. #define    MACH_RESTART_DATA_SIZE    0x14000        /* Enough space for the
  342.                          * initialized data of the
  343.                          * kernel to be stored in
  344.                          * a buffer. */
  345. #else
  346. #define    MACH_RESTART_DATA_SIZE    0x14000        /* No space needed. */
  347. #endif /* RECOV_NOCOPY */
  348.  
  349. #ifdef RECOV_TRANSPARENT
  350. /* This must be a multiple of the page size for now. */
  351. #define    MACH_RESTART_TABLE_SIZE    0xAA000        /* Space for a restart table. */
  352. #else
  353. #define    MACH_RESTART_TABLE_SIZE    0x4        /* No space needed. */
  354. #endif /* RECOV_TRANSPARENT */
  355.  
  356. /*
  357.  * More window-related constants
  358.  */
  359. #ifdef sun4c
  360.  
  361. #ifdef _ASM            /* force error */
  362.  
  363. #define    MACH_NUM_WINDOWS    %%
  364. #define    MACH_VALID_WIM_BITS    %%
  365.  
  366. #else /* _ASM */
  367.  
  368. #define    MACH_NUM_WINDOWS    machNumWindows    /* # of implemented windows */
  369.                         /* is wim value in range? */
  370. #define    MACH_VALID_WIM_BITS    ((1 << machNumWindows) - 1)
  371.  
  372. #endif /* _ASM */
  373.  
  374. #else /* sun4c */
  375.  
  376. #define    MACH_NUM_WINDOWS    7        /* # of implemented windows */
  377. #define    MACH_VALID_WIM_BITS    0x0000007f    /* is wim value in range? */
  378.  
  379. #endif /* sun4c */
  380.  
  381. #define    MACH_MAX_WINDOWS    8        /* for allocating array space */
  382.  
  383. /*
  384.  * The size of the floating point state size in Mach_RegState.
  385.  */
  386. #define    MACH_FP_STATE_SIZE (8 + (MACH_NUM_FPS*4) + (MACH_FPU_MAX_QUEUE_DEPTH*8))
  387. /*
  388.  * The size of a single saved window (locals and ins) in bytes.
  389.  */
  390. #define    MACH_SAVED_WINDOW_SIZE    (MACH_NUM_LOCALS * 4 + MACH_NUM_INS * 4)
  391.  
  392. /*
  393.  * The size of the state frame that's saved on interrupts, etc.  This must
  394.  * be the size of Mach_RegState, and this is checked in machCode.c.  We
  395.  * shouldn't succeed in booting if these constants are out of whack.  Keep
  396.  * it this way!  Size is in bytes.
  397.  */
  398. #define    MACH_SAVED_STATE_FRAME    (MACH_SAVED_WINDOW_SIZE + MACH_INPUT_STORAGE +\
  399.                 MACH_NUM_EXTRA_ARGS * 4 + MACH_NUM_GLOBALS * 4\
  400.                 + MACH_FP_STATE_SIZE)
  401.  
  402. /*
  403.  * The compiler stores parameters to C routines in its caller's stack frame,
  404.  * so this is at %fp + some_amount.  "Some_amount has to be below (higher addr)
  405.  * than the saved window area, so this means all routines that call C routines
  406.  * with arguments must have a stack frame that is at least
  407.  * MACH_SAVED_WINDOW_SIZE + MACH_INPUT_STORAGE = 96 bytes.  If the
  408.  * frame is also being used for trap state, then it's
  409.  * MACH_SAVED_STATE_FRAME + MACH_INPUT_STORAGE.  This MACH_INPUT_STORAGE is
  410.  * the space for calleeInputs in the Mach_Reg_State structure.
  411.  */
  412. #define    MACH_INPUT_STORAGE    (MACH_NUM_INS * 4)
  413.  
  414. /*
  415.  * Ugh, there are only 6 input register storage slots, and one "hidden param"
  416.  * slot for an agregate return value.  This is the space before the area
  417.  * where parameters past the 6th begin.
  418.  */
  419. #define    MACH_ACTUAL_HIDDEN_AND_INPUT_STORAGE    (7 * 4)
  420. /*
  421.  * Number of input registers really used as parameters.
  422.  */
  423. #define    MACH_NUM_REAL_IN_REGS    6
  424.  
  425. /*
  426.  * This doesn't include the space for extra params, since we never use
  427.  * it where extra params are needed.
  428.  */
  429. #define    MACH_FULL_STACK_FRAME    (MACH_SAVED_WINDOW_SIZE + MACH_INPUT_STORAGE)
  430.  
  431.  
  432. /*
  433.  * Constant for offset of first argument in a saved window area.
  434.  */
  435. #define    MACH_ARG0_OFFSET    (MACH_NUM_LOCALS * 4)
  436.  
  437. /*
  438.  * Constant for offset of fp in saved window area.  Fp is %i6.
  439.  */
  440. #define    MACH_FP_OFFSET        (MACH_NUM_LOCALS * 4 + 6 * 4)
  441. #define    MACH_FP_REG        6
  442.  
  443. /*
  444.  * Constant for offset of return pc in saved window area.  RetPC is %i7.
  445.  */
  446. #define    MACH_RETPC_OFFSET    (MACH_NUM_LOCALS * 4 + 7 * 4)
  447.  
  448. /*
  449.  * Constant for offset of return from trap pc reg in saved window area.
  450.  * RetFromTrap pc is %l1.
  451.  */
  452. #define    MACH_TRAP_PC_OFFSET    (4)
  453.  
  454. /*
  455.  * Constant for offset of saved psr in trap regs in saved window area.
  456.  * CurPsr is %l0.
  457.  */
  458. #define    MACH_PSR_OFFSET        (0)
  459.  
  460. /*
  461.  * Number of parameters beyond the sixth that are allowed on trap entry (for
  462.  * system calls.
  463.  */
  464. #define    MACH_NUM_EXTRA_ARGS    (SYS_MAX_ARGS - 6)
  465.  
  466. /*
  467.  * The number of registers.
  468.  * MACH_NUM_GLOBALS - Number of %g registers in sparc.
  469.  * MACH_NUM_INS     - Number of %i registers in sparc.
  470.  * MACH_NUM_LOCALS  - Number of %l registers in sparc.
  471.  * MACH_NUM_WINDOW_REGS - Number of registers in each window.
  472.  * MACH_NUM_FPS     - Number of %f registers in sparc. This registers may be
  473.  *              used as MACH_NUM_FPS floats or MACH_NUM_FPS/2 doubles or
  474.  *              MACH_NUM_FPS/4 extendeds.
  475.  * MACH_FPU_MAX_QUEUE_DEPTH - The maximum number of entires in the FPU queue
  476.  *                  of unfinished instructions.  This number is 
  477.  *                  implementation dependent with the current 
  478.  *                  value set to match SunOS 4.0.3.
  479.  * 
  480.  */
  481. #define    MACH_NUM_GLOBALS        8
  482. #define    MACH_NUM_INS            8
  483. #define    MACH_NUM_LOCALS            8
  484. #define    MACH_NUM_WINDOW_REGS        (MACH_NUM_LOCALS + MACH_NUM_INS)
  485. #define    MACH_NUM_FPS            32
  486. #define    MACH_FPU_MAX_QUEUE_DEPTH    16
  487. /*
  488.  * The amount to shift left by to multiply a number by the number of registers
  489.  * per window.  How would I get this from the constant above?
  490.  */
  491. #define    MACH_NUM_REG_SHIFT        4
  492.  
  493. /*
  494.  * Definitions of registers.
  495.  *
  496.  *
  497.  * The different types of registers.
  498.  *
  499.  *    r0 to r7    globals        g0 to g7
  500.  *    r8 to r15    outs        o0 to o7
  501.  *    r16 to r23    locals        l0 to l7
  502.  *    r24 to r31    ins        i0 to i7
  503.  *    f0 to f31    floating points
  504.  *
  505.  *        Special Registers:
  506.  *    current sp        = o6 = r14
  507.  *    current fp        = i6 = r30 = caller's sp
  508.  *    "0 & discard reg"    = g0 = r0
  509.  *    ret addr from C call    = o7 = r15 in old window
  510.  *    ret value from C call    = o0 = r8 in old window
  511.  *    ret addr to C call    = i7 = r31 in new window
  512.  *    ret val to C call    = i0 = r24 in new window
  513.  *    psr saved into        = l0 = r16 as first part of trap
  514.  *    ret pc from trap    = l1 = r17 in new window
  515.  *    ret npc from trap    = l2 = r18 in new window
  516.  *    tbr from trap        = l3 = r19 as first part of trap
  517.  *    y from trap        = l4 = r20 as first part of trap
  518.  *
  519.  * System routines may end up using a window pointed to by wim if a trap
  520.  * was taken before we got a window overflow.  In this case, they can use
  521.  * the local registers, but not the in or out registers, since they may be
  522.  * in use.  They can use global registers known to be free.
  523.  *
  524.  * NOTE: the order of the what's stored into the local routines is important
  525.  * since that's what gets saved on a stack frame for interrupts, etc.  If this
  526.  * changes, the corresponding changes need to be made in machAsmDefs.h and
  527.  * the mach.h definition of Mach_RegState.
  528.  *
  529.  *    RETURN_ADDR_REG    (r15)    Where the return address from a function call
  530.  *                is stored at call-time.
  531.  *    RETURN_ADDR_REG_CHILD (r31)
  532.  *                Where the called window finds return addr.
  533.  *    CUR_PSR_REG    (r16)    Register where psr is stored at trap time.
  534.  *    CUR_PC_REG    (r17)    Register where the first PC is stored on a trap.
  535.  *    NEXT_PC_REG    (r18)    Register where the 2nd PC is stored on a trap.
  536.  *    CUR_TBR_REG    (r19)    Register where the tbr is stored on a trap.
  537.  *    CUR_Y_REG    (r20)    Register where the y reg is stored on a trap.
  538.  *    SAFE_TEMP    (r21)     Register that cannot be modified by macros or
  539.  *                subroutines within the same window.
  540.  *    VOL_TEMP[1-2]    (r22-r23)
  541.  *                Volatile temporary registers.  Means that
  542.  *                macros in machAsmDefs.h can modify these
  543.  *                registers.
  544.  *    RETURN_VAL_REG    (r8)    Where a value is returned from a C routine.
  545.  *    RETURN_VAL_REG_CHILD (r24)
  546.  *                Where to return a value to our caller.
  547.  *
  548.  */
  549. #define    RETURN_ADDR_REG        r15        /* o7 */
  550. #define    RETURN_ADDR_REG_CHILD    r31        /* i7 */
  551. #define    CUR_PSR_REG        r16        /* l0 */
  552. #define    CUR_PC_REG        r17        /* l1 */
  553. #define    NEXT_PC_REG        r18        /* l2 */
  554. #define    CUR_TBR_REG        r19        /* l3 */
  555. #define    CUR_Y_REG        r20        /* l4 */
  556. #define    SAFE_TEMP        r21        /* l5 */
  557. #define    VOL_TEMP1        r22        /* l6 */
  558. #define    VOL_TEMP2        r23        /* l7 */
  559. #define    RETURN_VAL_REG        r8        /* o0 */
  560. #define    RETURN_VAL_REG_CHILD    r24        /* i0 */
  561. #define    OUT_TEMP1        r12        /* o4 */
  562. #define    OUT_TEMP2        r13        /* o5 */
  563.  
  564.  
  565. #endif /* _MACHCONST */
  566.